package com.ruoyi.supplier.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.supplier.domain.TbBankIncomeName;
import com.ruoyi.supplier.service.ITbBankIncomeNameService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 进账名目Controller
 * 
 * @author oliver.li
 * @date 2021-08-14
 */
@RestController
@RequestMapping("/supplier/bankIncomeName")
public class TbBankIncomeNameController extends BaseController
{
    @Autowired
    private ITbBankIncomeNameService tbBankIncomeNameService;

    /**
     * 查询进账名目列表
     */
    @PreAuthorize("@ss.hasPermi('supplier:bankIncomeName:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbBankIncomeName tbBankIncomeName)
    {
        startPage();
        List<TbBankIncomeName> list = tbBankIncomeNameService.selectTbBankIncomeNameList(tbBankIncomeName);
        return getDataTable(list);
    }

    /**
     * 导出进账名目列表
     */
    @PreAuthorize("@ss.hasPermi('supplier:bankIncomeName:export')")
    @Log(title = "进账名目", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TbBankIncomeName tbBankIncomeName)
    {
        List<TbBankIncomeName> list = tbBankIncomeNameService.selectTbBankIncomeNameList(tbBankIncomeName);
        ExcelUtil<TbBankIncomeName> util = new ExcelUtil<TbBankIncomeName>(TbBankIncomeName.class);
        return util.exportExcel(list, "进账名目数据");
    }

    /**
     * 获取进账名目详细信息
     */
    @PreAuthorize("@ss.hasPermi('supplier:bankIncomeName:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tbBankIncomeNameService.selectTbBankIncomeNameById(id));
    }

    /**
     * 新增进账名目
     */
    @PreAuthorize("@ss.hasPermi('supplier:bankIncomeName:add')")
    @Log(title = "进账名目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbBankIncomeName tbBankIncomeName)
    {
        return toAjax(tbBankIncomeNameService.insertTbBankIncomeName(tbBankIncomeName));
    }

    /**
     * 修改进账名目
     */
    @PreAuthorize("@ss.hasPermi('supplier:bankIncomeName:edit')")
    @Log(title = "进账名目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbBankIncomeName tbBankIncomeName)
    {
        return toAjax(tbBankIncomeNameService.updateTbBankIncomeName(tbBankIncomeName));
    }

    /**
     * 删除进账名目
     */
    @PreAuthorize("@ss.hasPermi('supplier:bankIncomeName:remove')")
    @Log(title = "进账名目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbBankIncomeNameService.deleteTbBankIncomeNameByIds(ids));
    }
}
